<?php

/**
 * Template form base class.
 *
 * @method Template getObject() Returns the current form's model object
 *
 * @package    25Mails
 * @subpackage form
 * @author     fabio.lorenzini@25solutions.com
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTemplateForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'template_id'     => new sfWidgetFormInputHidden(),
      'name'            => new sfWidgetFormInputText(),
      'language'        => new sfWidgetFormInputText(),
      'country'         => new sfWidgetFormInputText(),
      'sender_name'     => new sfWidgetFormInputText(),
      'sender_address'  => new sfWidgetFormInputText(),
      'subject'         => new sfWidgetFormInputText(),
      'body_txt'        => new sfWidgetFormTextarea(),
      'body_html'       => new sfWidgetFormTextarea(),
      'attachment'      => new sfWidgetFormTextarea(),
      'attachment_name' => new sfWidgetFormInputText(),
      'attachment_type' => new sfWidgetFormInputText(),
      'cc'              => new sfWidgetFormTextarea(),
      'bcc'             => new sfWidgetFormTextarea(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
      'deleted_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'template_id'     => new sfValidatorChoice(array('choices' => array($this->getObject()->get('template_id')), 'empty_value' => $this->getObject()->get('template_id'), 'required' => false)),
      'name'            => new sfValidatorString(array('max_length' => 255)),
      'language'        => new sfValidatorString(array('max_length' => 2, 'min_length' => 2, 'required' => false)),
      'country'         => new sfValidatorString(array('max_length' => 2, 'min_length' => 2, 'required' => false)),
      'sender_name'     => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'sender_address'  => new sfValidatorEmail(array('max_length' => 255)),
      'subject'         => new sfValidatorString(array('max_length' => 255)),
      'body_txt'        => new sfValidatorString(array('required' => false)),
      'body_html'       => new sfValidatorString(array('required' => false)),
      'attachment'      => new sfValidatorString(array('required' => false)),
      'attachment_name' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'attachment_type' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'cc'              => new sfValidatorString(array('max_length' => 1024, 'required' => false)),
      'bcc'             => new sfValidatorString(array('max_length' => 1024, 'required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
      'deleted_at'      => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('template[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Template';
  }

}
